class Solution(object):
    def lengthLongestPath(self, input):
        """
        :type input: str
        :rtype: int
        """
        input = input.split('\n')
        n = len(input)
        max_len = -1
        now_length = []
        for i in range(n):
            s = input[i].split('\t')
            f = s[-1]
            while len(s) <= len(now_length):
                now_length.pop()
            if '.' in f:
                if now_length:
                    max_len = max(max_len, now_length[-1] + len(f))
                else:
                    max_len = max(max_len, len(f))
            else:
                if now_length:
                    now_length.append(now_length[-1] + len(f) + 1)
                else:
                    now_length.append(len(f) + 1)
        return max_len




data = Solution()
input = "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext"
print(data.lengthLongestPath(input))
